home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt85jul.lbr
/
FORMAT.AQM
/
FORMAT.ASM
Wrap
Assembly Source File
|
1985-09-15
|
3KB
|
57 lines
ORG $300
JSR $DD67 ;Get the format length
JSR $E6FB ;Convert format length to single byte in X register
CPX #$10 ;Is the length greater or equal to 16?
BCC $030D ;No... continue on
JSR $E199 ;Print ?ILLEGAL QUANTITY ERROR, goto Applesoft
STX $06 ;Store the format length
JSR $DEBE ;Check for a comma (,)
JSR $DD67 ;Get the number of places following the decimal
JSR $E6FB ;Convert to a single byte in the X register
CPX #$09 ;Is the number of decimal places greater than 8?
BCS $030A ; Yes... go print error
CPX #$00 ;Is the number of decimal places equal to zero?
BEQ $030A ; Yes... go print error
STX $07 ; Store number of decimal places.
JSR $DEBE ;Check for comma (,)
JSR $DD67 ;Get the number to be formatted, store at $9D to $A3
JSR $ED34 ;Convert number to an ASCII string starting at $0100
LDX #$FF ;Initialize X as index
INX ;Increment index
LDA $0100,X ;Get an ASCII character
BEQ $0337 ;End of string? Yes... go calculate leading spaces
CMP #$2E ;Found a decimal point?
BNE $032D ; No... continue counting
STX $08 ;Store number of characters before decimal point
LDA $06 ;Get the format length
SEC ;Subtract from the length, the number of
SBC $07 ; places after the decimal and the number of
SBC $08 ; characters in front of the decimal.
TAX ;Store the result in X and decrement to
DEX ; allow form the decimal point.
BEQ $0349 ;If equal to zero continue on...
BMI $030A ;If less than zero go print error
JSR $F94A ;Print number of spaces in the X register
LDY $07 ;Get back number of decimal places in the Y register
LDX #$00 ;Initialize X as index
LDA $0100,X ;Get an ASCII character
BEQ $035C ;If end of string go print the decimal point.
CMP #$2E ;Is character a decimal point?
BEQ $0367 ; Yes... go print number of places after decimal
JSR $DB5C ;Print the character in the A register
INX ;Increment index to point to next ASCII character
BNE $034D ;Go get next character
LDA #$2E ;Load A register with ASCII value for decimal point
JSR $DB5C ;Print the decimal point
LDA #$30 ;Load A register with ASCII value for a zero (0)
DEY ;Decrement number of decimal places to be printed
BPL $035E ;Continue printing decimal places until done.
RTS ;Return to calling routine
JSR $DB5C ;Print the decimal point
INX ;Increment index to point to next ASCII character
LDA $0100,X ;Get an ASCII character
BEQ $0361 ;If end of string go finish printing
DEY ;Decrement number of decimal places to be printed
BPL $0367 ;Continue printing decimal places until done
RTS ;Return to calling routine
of decim